package org.example.filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author metalsbanyan
 * @version 1.0
 * @description: 跨域配置
 * @date 2023/7/22 15:12
 */
public class CrosFilter implements Filter {
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletResponse responseFacade = (HttpServletResponse) servletResponse;
        responseFacade.addHeader("Access-Control-Allow-Origin", "http://localhost:8081");
        responseFacade.addHeader("Access-Control-Allow-Credentials", "true");
        filterChain.doFilter(servletRequest, servletResponse);
    }
}
